Attribute VB_Name = "modInterface"
'---------------------------------------------------------------------------------------
'Module : modInterface
'Date   : 07/14/2004
'Author : Chris Elwell
'Purpose: Routines customers can call to interface with the client
'
'2005-03-29, JFW, Adopt source version 720.3.1
'2005-03-29, JFW, Commodity tables field order 120, 414, 1030, 1275, 119.
'
'---------------------------------------------------------------------------------------
'
'---------------------------------------------------------------------------------------
' Procedure : SetMessage()
' DateTime  : 6/9/2004
' Purpose   : Sets the lblMessage text, fontsize, forecolor, and fontbold properties on
'             frmShip.
'---------------------------------------------------------------------------------------
'
Public Sub SetMessage(ByVal strText As String, Optional intFontSize As Integer = 12, Optional vntForeColor As Variant = vbBlack, Optional blnFontBold As Boolean = True)
    
    frmShip.lblMessage.Caption = strText
    frmShip.lblMessage.FontSize = intFontSize
    frmShip.lblMessage.ForeColor = vntForeColor
    frmShip.lblMessage.FontBold = blnFontBold

End Sub
'---------------------------------------------------------------------------------------
' Procedure : SaveBoxDIMs
' DateTime  : 07/7/2004
' Purpose   : Add or update Box DIMs in Dimensions table
' Call from :
'---------------------------------------------------------------------------------------
'
Public Sub SaveBoxDIMs(ByVal strBoxName As String, ByVal str57 As String, ByVal str58 As String, ByVal str59 As String)
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:SaveBoxDIMs"
    
    Dim rsBoxDIMs As New ADODB.Recordset
    Dim strQuery As String
    
    strQuery = "SELECT * FROM Dimensions WHERE BoxName = " & SingleQuotes(strBoxName)
    rsBoxDIMs.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic
    
    If rsBoxDIMs.EOF Then
        strQuery = "INSERT INTO Dimensions VALUES ("
        strQuery = strQuery + SingleQuotes(strBoxName) + ","
        strQuery = strQuery + SingleQuotes(str57) + ","
        strQuery = strQuery + SingleQuotes(str58) + ","
        strQuery = strQuery + SingleQuotes(str59) + ")"
        g_connFSMSClient.Execute strQuery
    Else
        strQuery = "UPDATE Dimensions SET [BoxName] = " + SingleQuotes(strBoxName) + ","
        strQuery = strQuery + "[g_str57] = " + SingleQuotes(str57) + ","
        strQuery = strQuery + "[g_str58] = " + SingleQuotes(str58) + ","
        strQuery = strQuery + "[g_str59] = " + SingleQuotes(str59)
        strQuery = strQuery + " WHERE BoxName = " + SingleQuotes(strBoxName)
        g_connFSMSClient.Execute strQuery
    End If
    
Release:

    If rsBoxDIMs.State = adStateOpen Then
        rsBoxDIMs.Close
    End If
    Set rsBoxDIMs = Nothing
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release

End Sub
'---------------------------------------------------------------------------------------
' Procedure : SetCurrentAccount
' DateTime  : 07/12/2004
' Purpose   : Can be used to set the current shipping account programmatically.
'             Pass the account # of the desired account.
' Call from :
'---------------------------------------------------------------------------------------
'
Public Function SetCurrentAccount(ByVal strAcctNum As String) As Boolean

    Dim intListIndex As Integer     'Stores the current ListIndex after
    Dim i As Integer
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:SetCurrentAccount"
    
    'Loop through the combo list and see if acct# matches any entry. If yes, set the ListIndex
    'to the index then save the settings and return true.
    With frmSetup
        For i = 0 To .f10.ListCount - 1
            If strAcctNum = .f10.List(i) Then
                .f10.ListIndex = i
                Call .cmdSave_Click(0)
                SetCurrentAccount = True
                Exit For
            End If
        Next
    End With
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : SetCurrentIORFacility
' DateTime  : 11/5/2004
' Purpose   : Can be used to set the current IPD IOR Facility Code programmatically.
'             Pass the code of the desired account.
' Call from :
'---------------------------------------------------------------------------------------
'
Public Function SetCurrentIORFacility(ByVal strIORFacility As String) As Boolean

    Dim intListIndex As Integer     'Stores the current ListIndex after
    Dim i As Integer
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:SetCurrentIORFacility"
    
    'Loop through the combo list and see if IOR Code matches any entry. If yes, set the ListIndex
    'to the index then save the settings and return true.
    With frmShip
        For i = 0 To .f1355.ListCount - 1
            If strIORFacility = .f1355.List(i) Then
                .f1355.ListIndex = i
                SetCurrentIORFacility = True
                Exit For
            End If
        Next
    End With
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : SetCurrentAltReturnAddr
' DateTime  : 2/2/2005
' Purpose   : Can be used to set the current Alt Return Address programmatically.
'             Pass the AddrID of the desired address.
' Call from :
'---------------------------------------------------------------------------------------
'
Public Function SetCurrentAltReturnAddr(ByVal strAddrID As String) As Boolean

    Dim intListIndex As Integer     'Stores the current ListIndex after
    Dim i As Integer
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:SetCurrentAltReturnAddr"
    
    'Loop through the combo list and see if AddrID matches any entry. If yes, set the ListIndex
    'to the index then save the settings and return true.
    With frmSetup
        For i = 0 To .cboAddrID.ListCount - 1
            If strAddrID = .cboAddrID.List(i) Then
                .cboAddrID.ListIndex = i
                Call .cmdSave_Click(0)
                SetCurrentAltReturnAddr = True
                Exit For
            End If
        Next
    End With
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : InsertIntlCommodities
' DateTime  : 07/14/2004
' Modified  : 01/05/2005
' Purpose   : Allows customers to enter Intl Commodities programmatically rather than
'             through the interface.
'---------------------------------------------------------------------------------------
'
Public Function InsertIntlCommodities(str1 As String, str77 As String, str79 As String, _
                                str80 As String, str81 As String, str82 As String, _
                                str83 As String, str84 As String, str120 As String, str414 As String, _
                                str1030 As String, str119 As String, str1275 As String) As Boolean
    
    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:InsertIntlCommodities"
    
    If str1 = "" Then
        InsertIntlCommodities = False
        Exit Function
    End If
    
    strQuery = "INSERT INTO IntlCommodities VALUES (" & SingleQuotes(str1) & ","
    strQuery = strQuery + SingleQuotes(str77) & ","
    strQuery = strQuery + SingleQuotes(str79) & ","
    strQuery = strQuery + SingleQuotes(str80) & ","
    strQuery = strQuery + SingleQuotes(str81) & ","
    strQuery = strQuery + SingleQuotes(str82) & ","
    strQuery = strQuery + SingleQuotes(str83) & ","
    strQuery = strQuery + SingleQuotes(str84) & ","
    strQuery = strQuery + SingleQuotes(str120) & ","
    strQuery = strQuery + SingleQuotes(str414) & ","
    strQuery = strQuery + SingleQuotes(str1030) & ","
    strQuery = strQuery + SingleQuotes(str119) & ","
    strQuery = strQuery + SingleQuotes(str1275) & ")"
    
    g_connFSMSClient.Execute strQuery
    InsertIntlCommodities = True
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : DeleteIntlCommodities
' DateTime  : 07/14/2004
' Purpose   : Allows customers to delete Intl Commodities programmatically rather than
'             through the interface.
'---------------------------------------------------------------------------------------
'
Public Function DeleteIntlCommodities(strOrderID As String) As Boolean

    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:DeleteIntlCommodities"
    
    If strOrderID = "" Then
        DeleteIntlCommodities = False
        Exit Function
    End If
    
    strQuery = "DELETE FROM IntlCommodities WHERE f1 = " & SingleQuotes(strOrderID)
    
    g_connFSMSClient.Execute strQuery
    DeleteIntlCommodities = True
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation


End Function
'---------------------------------------------------------------------------------------
' Procedure : InsertMPS
' DateTime  : 07/14/2004
' Purpose   : Allows customers to enter Domestic MPS programmatically rather than
'             through the interface.
'---------------------------------------------------------------------------------------
'
Public Function InsertMPS(str1 As String, str1670 As String, str57 As String, _
                                str58 As String, str59 As String, str26 As String, _
                                str25 As String, str3056 As String, str3057 As String, _
                                str3018 As String) As Boolean

    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:InsertMPS"
    
    If str1 = "" Then
        InsertMPS = False
        Exit Function
    End If
    
    strQuery = "INSERT INTO MPS VALUES (" & SingleQuotes(str1) & ","
    strQuery = strQuery + SingleQuotes(str1670) & ","
    strQuery = strQuery + SingleQuotes(str57) & ","
    strQuery = strQuery + SingleQuotes(str58) & ","
    strQuery = strQuery + SingleQuotes(str59) & ","
    strQuery = strQuery + SingleQuotes(str26) & ","
    strQuery = strQuery + SingleQuotes(str25) & ","
    strQuery = strQuery + SingleQuotes(str3056) & ","
    strQuery = strQuery + SingleQuotes(str3057) & ","
    strQuery = strQuery + SingleQuotes(str3018) & ","
    strQuery = strQuery + SingleQuotes(Date) & ")"

    g_connFSMSClient.Execute strQuery
    InsertMPS = True
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Function
'---------------------------------------------------------------------------------------
' Procedure : DeleteMPS
' DateTime  : 07/14/2004
' Purpose   : Allows customers to delete Dom MPS programmatically rather than
'             through the interface.
'---------------------------------------------------------------------------------------
'
Public Function DeleteMPS(strOrderID As String) As Boolean

    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "modInterface:DeleteMPS"
    
    If strOrderID = "" Then
        DeleteMPS = False
        Exit Function
    End If
    
    strQuery = "DELETE FROM MPS WHERE f1 = " & SingleQuotes(strOrderID)
    
    g_connFSMSClient.Execute strQuery
    DeleteMPS = True
    
    Exit Function
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation


End Function
